import * as fs from 'fs'

export class WindowsPathUtil {
  // Windows路径转换
  static normalize(filepath: string): string {
    return filepath.replace(/\\/g, '/')
  }

  // 获取Windows系统路径
  static getSystemPaths() {
    return {
      data: 'C:\\ProgramData\\LivePlatform',
      logs: 'C:\\ProgramData\\LivePlatform\\logs',
      temp: 'C:\\ProgramData\\LivePlatform\\temp',
      upload: 'C:\\ProgramData\\LivePlatform\\upload',
      ffmpeg: 'C:\\Program Files\\ffmpeg\\bin\\ffmpeg.exe',
      bills: 'C:\\ProgramData\\LivePlatform\\bills',
      reports: 'C:\\ProgramData\\LivePlatform\\reports',
      certificates: 'C:\\ProgramData\\LivePlatform\\certificates',
    }
  }

  // 创建必要的目录
  static async ensureDirectories() {
    const paths = this.getSystemPaths()
    for (const [key, dir] of Object.entries(paths)) {
      // 跳过ffmpeg路径，因为它是一个文件路径
      if (key !== 'ffmpeg') {
        await fs.promises.mkdir(dir, { recursive: true })
      }
    }
  }
}
